package org.example.biz.impl;

import org.example.biz.GlobalBiz;
import org.example.oa.dao.EmployeeDao;
import org.example.oa.entity.Employee;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

/**
 * 员工登录、修改密码等功能
 */
@Service("globalBiz")
public class GlobalBizImpl implements GlobalBiz {

    @Autowired
    private EmployeeDao employeeDao;

    //登陆成功返回employee对象
    public Employee login(String sn, String password) {
        Employee employee = employeeDao.select(sn);
        //数据库由编号为sn的记录并且密码正确
        if(employee!=null && employee.getPassword().equals(password)){
            return employee;
        }
        return null;
    }
    //修改密码直接设置为有新密码的employee对象
    public void changePassword(Employee employee) {
        employeeDao.update(employee);
    }
}
